
#include "ifi_aliases.h"
#include "ifi_default.h"
#include "ifi_utilities.h"
#include "user_routines.h"
#include "printf_lib.h"
#include "delays.h"

/*******************************************************************************
* FILE NAME: lovitt_routines.c
*
* DESCRIPTION: 
*  utility routines for use in user_routines.c
*
* 
*******************************************************************************/

long leftError;
long rightError;
extern int right_Wheel_Counter , left_Wheel_Counter;




/*******************************************************************************
* FUNCTION NAME: integrateError
* PURPOSE:       Calculate accumulated error during navigation (I of a PID control system)
* CALLED FROM:   user_routines_fast
* ARGUMENTS:     right goal tooth count, left goal tooth count
* RETURNS:       void
*******************************************************************************/


void integrateError(int lGoal, int rGoal)
{
	rightError += difference(rGoal,right_Wheel_Counter) ;
	leftError += difference(lGoal,left_Wheel_Counter) ;	
}